package edu.rakovic.elearning.services;

import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.MappedConfiguration;

import edu.rakovic.elearning.beans.CourseBean;
import edu.rakovic.elearning.beans.UserBean;
import edu.rakovic.elearning.enums.Role;
import edu.rakovic.elearning.interfaces.Course;
import edu.rakovic.elearning.interfaces.User;
import edu.rakovic.elearning.service.Applications;
import edu.rakovic.elearning.service.ApplicationsBean;
import edu.rakovic.elearning.service.Contents;
import edu.rakovic.elearning.service.ContentsBean;
import edu.rakovic.elearning.service.Courses;
import edu.rakovic.elearning.service.CoursesBean;
import edu.rakovic.elearning.service.Exams;
import edu.rakovic.elearning.service.ExamsBean;
import edu.rakovic.elearning.service.Users;
import edu.rakovic.elearning.service.UsersBean;

public class AppModule {

	public static void contributeApplicationDefaults(
			MappedConfiguration<String, String> configuration) {

		configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
		configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
	}
	
	
	public static Users buildUsers(){
		
		Users users = new UsersBean();
		User user = new UserBean();
		user.setFullName("Vesko Rakovic");
		user.setPassword("admin");
		user.setUserName("admin");
		user.setRole(Role.ADMINISTRATOR);
		users.save(user);
		
		User user2 = new UserBean();
		user2.setFullName("Marko Markovic");
		user2.setPassword("teacher");
		user2.setUserName("teacher");
		user2.setRole(Role.TEACHER);
		users.save(user2);
		
		User user3 = new UserBean();
		user3.setFullName("Janko Jankovic");
		user3.setPassword("student");
		user3.setUserName("student");
		user3.setRole(Role.STUDENT);
		users.save(user3);
		
		return users;
	}
	
	public static Courses buildCourses(){
//		Courses courses = new CoursesBean();
//		Course course = new CourseBean();
//		User teacher = new UserBean();
//		teacher.setFullName("AppModule");
//		teacher.setUserName("tt");
//		teacher.setRole(Role.TEACHER);
//		course.executeCourseCreation("Programming", "first course", teacher);
//		courses.save(course);
		return new CoursesBean();
	}
	
	public static Applications buildApplications(){
		return new ApplicationsBean();
	}
	
	public static Exams buildExams(){
		return new ExamsBean();
	}
	
	public static Contents buildContents(){
		return new ContentsBean();
	}

}